// pages/appraise_list/appraise_list.js
const app = getApp(), core = require('../../utils/core'), util = require('../../utils/util');
Page({

  /**
   * 页面的初始数据
   */
  data: {

    comments: [],
    commentsMore: {page:1},
    total: '',
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.getSystemInfo({
      success: function (res) {
        //model中包含着设备信息
        console.log(res.model)
        var model = res.model
        if (model.search('iPhone X') != -1) {
          app.globalData.isIpx = true;
        } else {
          app.globalData.isIpx = false;
        }
      }
    })
    let isPhone = app.globalData.isIpx;
    if (isPhone) {
      this.setData({
        ipx: true
      })
    }
    this.setData({jobId:options.id});
    this.fetch();
  },
  fetch() {
    util.fetch(this, 'xilujob.interview_comment/lists', {job_id:this.data.jobId}, 'commentsMore', 'comments', 'data', data=>{
      this.setData({canComment: data.can_comment});
      this.setData({comments: data.data});
    })
  },
  goComment() {
    wx.navigateTo({url: '/pages/post_job_comment/post_job_comment?id='+this.data.jobId,events:{
      'commented': data => {
        this.refresh();
      }
    }})
  },
  refresh() {
    this.setData({comments:[], commentsMore: {page:1}});
    this.fetch();
  },

});
